package com.qfmy.mystation.ui.activity;

import android.os.Bundle;
import android.view.KeyEvent;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.qfmy.mystation.R;
import com.qfmy.mystation.databinding.ActivityWallpaperBinding;

public class WallpaperActivity extends AppCompatActivity {
    private ActivityWallpaperBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityWallpaperBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        setSupportActionBar(binding.toolbar);
        BottomNavigationView navBottom = binding.navBottom;
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.nav_static_wallpaper, R.id.nav_live_wallpaper, R.id.nav_my_wallpaper)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.fc_wallpaper);
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navBottom, navController);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        System.out.println("wallpaper destroy!");
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            moveTaskToBack(true);
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}